﻿using System.Text.RegularExpressions;
using System;

namespace TrafficSplitter
{
    class Constants
    {
        public const String NO_INTERFACES = " [ No interface selected ] ";
        public const String UPDATE_URL = "https://traffic-splitter.googlecode.com/files/version-info";
        public const String UPDATE_PAGE = "http://code.google.com/p/traffic-splitter/downloads/";
        public static String [] ADAPTER_ACTIONS = {"No Action", "Disconnect", "Connect", "Connecting", "Disconnecting"};
        public static String [] INTERFACE_NAMES = { "International", "Local Only", "Auxilary", "Auxilary 2", "Auxilary 3" };
        public static String [] FILENAMES = { "introutes.dat", "localroutes.dat", "auxroutes.dat", "aux2routes.dat", "aux3routes.dat" };
        public static String [] LOCAL_ROUTES_URL = { "http://developers.locality.co.za/routes-rs.txt", "http://developers.locality.co.za/maxmind-routes-rs.txt", "http://developers.locality.co.za/sadc-routes-rs.txt", "http://developers.locality.co.za/routes-nonpeered-rs.txt" };
        public static String [] AUXILARY_ROUTES_URL = { "http://developers.locality.co.za/routes-mweb-rs.txt", "http://traffic-splitter.googlecode.com/files/wage-rs.txt" };
        public const String GET_LOCAL_IP = "http://www.whatsmyip.co.za/ddclient.php";
        public const String GET_INT_IP = "http://checkip.dyndns.org/ddclient.php";
        public const Int16 MAX_INTERFACES = 5;
        public const Int16 DIALER_TIMEOUT = 30000;
        public static Regex ipAndMaskPattern = new Regex("^([0-9]+.){3}[0-9]+,([0-9]+.){3}[0-9]+");
        public static Regex ipPattern = new Regex("([0-9]+.){3}[0-9]+");
        public static Main main;

        public static void AppendToLog(LOG_TYPE type, String str)
        {
            main.AppendToLog(type, str);
        }

        public static void AppendToLogBuffer(LOG_TYPE type, String str)
        {
            main.AppendToLogBuffer(type, str);
        }

        public static void FlushLogBuffer()
        {
            main.FlushLogBuffer();
        }
    }
    
    // List of interfaces
    public enum TS_INTERFACES
    {
        International = 0,
        Local = 1,
        Auxilary = 2,
        Auxilary2 = 3,
        Auxilary3 = 4,
        All = -1
    }

    // List of log entry types
    public enum LOG_TYPE
    {
        Info = 0,
        Debug = 1,
        Warning = 2,
        Error = 3
    }

    // Virtual adapter states
    public enum TS_STATES
    {
        Connected = 1,
        Disconnected = 2,
        Dialing = 3,
        Disconnecting = 4,
        Unknown = 0
    }

    // Virtual adapter types
    public enum TS_ADAPTER_TYPES
    {
        None = 0,
        NetworkAdapter = 1,
        RASDevice = 2
    }

    // Connection states used for WMI query
    public enum TS_CONN_STATUS
    {
        Disabled = 0,
        Disconnected = 0,
        Connecting = 1,
        Connected = 2,
        Enabled = 2,
        Disconnecting = 3,
        HardwareNotPresent = 4,
        HardwareDisabled = 5,
        HardwareMalfunction = 6,
        MediaDisconnected = 7,
        Authenticating = 8,
        AuthenticationSucceeded = 9,
        AuthenticationFailed = 10,
        InvalidAddress = 11,
        CredentialsRequired = 12,
        NotAvailable = 13
    }
}